package gui.edit.components;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import gui.edit.listeners.ListenerActorsRelation;
import gui.edit.utils.Actor;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

/**
 * @author Charles Perin
 * 29 mars 2011
 * LIMSI - INRIA Rennes
 * charles.perin@free.fr
 *
 */
public class TwoActorsRelationPanel extends JPanel{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1711238170633286429L;

	private Actor actor1, actor2;
	
	private JRadioButton boxActor1Dominates;
	private JRadioButton boxActor2Dominates;
	private JRadioButton boxAffinity;
	private JLabel labelActor1,labelActor2;
	
	public static final Font normalSize = new Font("SansSerif", Font.BOLD, 12);
	public static final Font bigSize = new Font("SansSerif", Font.BOLD, 14);
	public static final Font smallSize = new Font("SansSerif", Font.PLAIN, 10);
	
	public TwoActorsRelationPanel(Actor actor1, Actor actor2){
		this.setActor1(actor1);
		this.setActor2(actor2);
		
		setPreferredSize(new Dimension(160,30));
		setBorder(BorderFactory.createLineBorder(Color.BLACK));
		
		ButtonGroup group = new ButtonGroup();

		boxActor1Dominates=new JRadioButton();
		boxActor2Dominates=new JRadioButton();
		boxAffinity=new JRadioButton();
		
		boxActor1Dominates.addActionListener(new ListenerActorsRelation(this));
		boxActor2Dominates.addActionListener(new ListenerActorsRelation(this));
		boxAffinity.addActionListener(new ListenerActorsRelation(this));
		
		boxActor1Dominates.setToolTipText(actor1.getName()+" dominates "+actor2.getName());
		boxActor2Dominates.setToolTipText(actor2.getName()+" dominates "+actor1.getName());
		boxAffinity.setToolTipText("affinity between "+actor1.getName()+" and "+actor2.getName());
		
		boxAffinity.setSelected(true);
		group.add(boxActor1Dominates);
		group.add(boxActor2Dominates);
		group.add(boxAffinity);
		
		labelActor1 = new JLabel(actor1.getName(), JLabel.LEFT);
		labelActor1.setFont(normalSize);
		labelActor2 = new JLabel(actor2.getName(), JLabel.RIGHT);
		labelActor2.setFont(normalSize);
		
		setLayout(new BorderLayout());
		
		Box box = Box.createHorizontalBox();
		box.add(labelActor1);
		box.add(Box.createGlue());
		box.add(Box.createHorizontalStrut(5));
		box.add(boxActor1Dominates);
		box.add(boxAffinity);
		box.add(boxActor2Dominates);
		box.add(Box.createGlue());
		box.add(Box.createHorizontalStrut(5));
		box.add(labelActor2);
		
		add(box,BorderLayout.CENTER);
	}

	public JRadioButton getBoxActor1Dominates() {
		return boxActor1Dominates;
	}

	public void setBoxActor1Dominates(JRadioButton boxActor1Dominates) {
		this.boxActor1Dominates = boxActor1Dominates;
	}

	public JRadioButton getBoxActor2Dominates() {
		return boxActor2Dominates;
	}

	public void setBoxActor2Dominates(JRadioButton boxActor2Dominates) {
		this.boxActor2Dominates = boxActor2Dominates;
	}

	public JRadioButton getBoxAffinity() {
		return boxAffinity;
	}

	public void setBoxAffinity(JRadioButton boxAffinity) {
		this.boxAffinity = boxAffinity;
	}

	public JLabel getLabelActor1() {
		return labelActor1;
	}

	public void setLabelActor1(JLabel labelActor1) {
		this.labelActor1 = labelActor1;
	}

	public JLabel getLabelActor2() {
		return labelActor2;
	}

	public void setLabelActor2(JLabel labelActor2) {
		this.labelActor2 = labelActor2;
	}

	public void setActor1(Actor actor1) {
		this.actor1 = actor1;
	}

	public Actor getActor1() {
		return actor1;
	}

	public void setActor2(Actor actor2) {
		this.actor2 = actor2;
	}

	public Actor getActor2() {
		return actor2;
	}
	
	



}

